<?php

namespace App\Http\Controllers\Article;

use App\Http\Controllers\Controller;
use App\Models\Article;
use App\Models\Channel;
use App\Models\Navigation;
use Illuminate\Http\Request;

class ListController extends Controller
{
    // 文章列表
    public function index($channel = 1,$page = 1)
    {
        // 获取channel 。 并获取channel下的所有文章
        $request = Request::capture();
        $child = Channel::find($request->input('c',1))->childNode();
        $map = count($child) > 0 ? $child : [$request->input('c',1)];

        $articles = Article::whereIn('categroy', $map)->seoPaginate($page);

        return view('article.list',compact('articles'));
    }
}
